﻿using System;
using System.Runtime.Serialization;
using Maple.Weixin.MP.Entities.JsonResult;

namespace Maple.Weixin.MP.Exceptions
{
    /// <summary>
    /// 标记微信请求错误，只要返回errorcode不为0就是该类异常。
    /// </summary>
    public class WeixinRequestException : Exception
    {
        private readonly WeixinServiceResult weixinServiceResult;

        public WeixinRequestException(WeixinServiceResult result) {
            this.weixinServiceResult = result;
        }
        public WeixinRequestException(string message, WeixinServiceResult result) : base(message) {
            this.weixinServiceResult = result;
        }
        public WeixinRequestException(string message, Exception innerException, WeixinServiceResult result)
            : base(message, innerException) {
            this.weixinServiceResult = result;
        }
        public WeixinRequestException(SerializationInfo info, StreamingContext context, WeixinServiceResult result)
            : base(info, context) {
            this.weixinServiceResult = result;
        }

        public WeixinServiceResult WeixinServiceResult {
            get { return weixinServiceResult; }
        }
    }
}
